package miracle.joker.design.proxy;

import java.util.HashMap;
import java.util.Map;

public class CrawlerProxy implements Crawler {
    private Map<String, String> cache = new HashMap<>();
    private Crawler crawler = new CrawlerImpl();

    @Override
    public String getData(String url) {
        String data = cache.get(url);
        if (data == null) {
            data = crawler.getData(url);
            cache.put(url, data);
        }
        return data;
    }
}
